/**
 * @program: 2022.2.25异常
 * @description:
 * @author: 李鑫月
 * @create: 2022-02-25 16:00
 **/
public class TestDemo {
    public static void main(String[] args) {

        try {
            func(0);
        }catch (ArithmeticException e){
            e.printStackTrace();


        }
    }
    public static void func(int a) throws ArithmeticException{
        if(a==0)

        throw new ArithmeticException("qqqqqqqqq");

    }
    public static void main2(String[] args) {
        int[] arr={1,2,3};
        try {
            arr=null;
            System.out.println(arr[5]);
            System.out.println("aaa");
        }catch (ArrayIndexOutOfBoundsException  |NullPointerException e){
            e.printStackTrace();
            System.out.println("数组越界异常/空指针异常");
        }
    }

    public static void main1(String[] args) {
        int[] arr={1,2,3};
        try {
            arr=null;
            System.out.println(arr[5]);
            System.out.println("aaa");
        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            System.out.println("数组越界异常");
        }catch (NullPointerException e){
            System.out.println("捕捉到空指针异常");
        }
    }
}
